package com.org.zp.app;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Application;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.util.Log;

import com.baidu.location.LocationClient;
import com.org.base.lazylist.ImageLoader;
import com.org.zp.entity.login.UserInfo;

public class RecApp extends Application {

	public UserInfo user = new UserInfo();

	public ImageLoader imageLoader = new ImageLoader(this);

	public String mPayConBjData = "";
	public int mPayData = -1;
	public boolean mPayIsCon = false;
	public boolean mPayIsJY = true;
	public HashMap<String, String> mPaySelectID = new HashMap<String, String>();
	public int mPayNum = -1;
	public String mPayConQuery = "";

	// For NetWork Connect
	public boolean isNetWorkConnection = false;

	// 职位查询
	public HashMap<String, String> hPositionName = new HashMap<String, String>();
	public HashMap<String, String> hPositionId = new HashMap<String, String>();

	public ArrayList<HashMap<String, String>> hPositionCategory = new ArrayList<HashMap<String, String>>();// 职位类别
	public ArrayList<HashMap<String, String>> hPositionCity = new ArrayList<HashMap<String, String>>(); // 城市大类

	public ArrayList<HashMap<String, String>> hPositionIndustry = new ArrayList<HashMap<String, String>>(); // 行业类别
	public ArrayList<HashMap<String, String>> hPositionPay = new ArrayList<HashMap<String, String>>(); // 工资范围
	public ArrayList<HashMap<String, String>> hPositionNature = new ArrayList<HashMap<String, String>>(); // 职位性质
	public ArrayList<HashMap<String, String>> hPositionComSize = new ArrayList<HashMap<String, String>>(); // 公司规模

	// 薪酬查询
	public HashMap<String, String> hPayName = new HashMap<String, String>();
	public HashMap<String, String> hPayId = new HashMap<String, String>();
	
	//我的简历
	public ArrayList<HashMap<String, String>> hMyzpExp = new ArrayList<HashMap<String, String>>(); // 工作经验
	public ArrayList<HashMap<String, String>> hMyzpEdu = new ArrayList<HashMap<String, String>>(); // 学历

	public String alertIdString = "";
	public String keyword = "";

	@Override
	public void onCreate() {
		super.onCreate();
		
		Log.e("TMG", "application oncreate");

	}

	// Version
	private String version = "";

	public String getVersion() {
		if (version.equals("")) {
			try {
				PackageManager packageManager = getPackageManager();
				PackageInfo packInfo = packageManager.getPackageInfo(
						getPackageName(), 0);
				version = packInfo.versionName;
			} catch (Exception e) {
			}
		}
		return version;
	}

	private String phonetype = "";

	public String getPhoneType() {
		try {
			phonetype = android.os.Build.MODEL;
		} catch (Exception e) {
			// 获得手机型号
			phonetype = "无法获取型号";
		}
		return phonetype;
	}

	// IMEI
	private String imei = "";

	public String getImei() {
		try {
			if (imei.equals("")) {
				TelephonyManager tm = (TelephonyManager) this
						.getSystemService(Context.TELEPHONY_SERVICE);
				imei = tm.getDeviceId();
			}
		} catch (Exception e) {

		}

		return imei;
	}

	// IMSI
	private String imsi = "";

	public String getImsi() {
		try {
			if (imsi.equals("")) {

				// pad
				/*
				 * imsi = Secure.getString(this.getContentResolver(),
				 * Secure.ANDROID_ID);
				 */

				// 非pad
				// imsi = ((TelephonyManager)
				// this.getSystemService(Context.TELEPHONY_SERVICE)).getSubscriberId();

				// 判断当前是否是平板设备

				if (isPad()) {
					imsi = Secure.getString(this.getContentResolver(),
							Secure.ANDROID_ID);
				} else {
					imsi = ((TelephonyManager) this
							.getSystemService(Context.TELEPHONY_SERVICE))
							.getSubscriberId();
				}

			}
		} catch (Exception e) {
			imsi = "";
			e.printStackTrace();
		}

		return imsi;
	}

	private String phone = "";

	public String getPhone() {
		try {
			if (phone.equals("")) {

				// pad
				// phone = "";

				// 手机
				// phone = ((TelephonyManager)
				// this.getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number();

				// 判断当前是否是平板设备

				if (isPad()) {
					phone = "";
				} else {
					phone = ((TelephonyManager) this
							.getSystemService(Context.TELEPHONY_SERVICE))
							.getLine1Number();
				}

			}
		} catch (Exception e) {
			phone = "";
			e.printStackTrace();
		}

		return phone;
	}

	public boolean isPad() {
		TelephonyManager tm = (TelephonyManager) this
				.getSystemService(Context.TELEPHONY_SERVICE);
		int type = tm.getPhoneType();

		// 判断当前是否是平板设备
		if (type == TelephonyManager.PHONE_TYPE_NONE) {
			return true;
		} else {
			return false;
		}
	}

}
